from pydantic import BaseModel, ValidationError, constr, Field
from typing import Optional
from common import ai

# BaseModel是flask pydantic包提供的一个基础类，ParamOutline是这个BaseModel的继承类
# 继承Pydantic的好处在于 Pydantic可以很容易的处理  数据验证，序列化，数据格式转换如dictionary-json等操作。

"""
google靠不住
qianwen太慢
gpt收费贵

需要找到一个收费不太贵，速度还可以的。
"""
_defaultModel = ai.MODEL_QIANWEN

_defaultModel = ai.MODEL_GPT35

# _defaultModel = common.MODEL_GEMINI10


class _BaseFields(BaseModel):
    isVipUser: Optional[bool] = True
    userId: Optional[int] = 9527


class ParamChat(_BaseFields):
    userMessage: Optional[str] = ""


# 生成标题
class ParamTitle(_BaseFields):
    domain: str
    level: Optional[str] = Field(default="本科")
    lang: Optional[str] = Field(default="中文")
    topic: Optional[str] = Field(default="")
    keyword: Optional[str] = Field(default="")
    keyword1: Optional[str] = Field(default="")
    size: Optional[int] = Field(default=4)
    model: Optional[str] = ai.MODEL_KIMI


# 生成提纲
class ParamOutline(_BaseFields):
    title: str
    # 这是一种来自Pydantic的定义属性attribute的方法
    length: Optional[int] = Field(default="800")
    level: Optional[str] = Field(default="本科")
    lang: Optional[str] = Field(default="中文")
    paragraphCount: Optional[int] = Field(default=6)
    secondParagraphCount: Optional[int] = Field(default=3)
    author: Optional[str] = Field(default="", description="作者身份说明")
    style: Optional[str] = Field(default="", description="成文风格")
    model: Optional[str] = ai.MODEL_GEMINI10


# 不连ai，选择一个提纲
class ParamSelect4Content(_BaseFields):
    title: str
    # 这是一种来自Pydantic的定义属性attribute的方法
    length: Optional[str] = Field(default="800")
    level: Optional[str] = Field(default="本科")
    lang: Optional[str] = Field(default="中文")
    outline: dict
    model: Optional[str] = _defaultModel


# 全部生成
class ParamGetContentFromOutline(_BaseFields):
    title: str
    # 这是一种来自Pydantic的定义属性attribute的方法
    length: Optional[str] = Field(default="800")
    level: Optional[str] = Field(default="本科")
    lang: Optional[str] = Field(default="中文")
    outline: dict
    thesisId: Optional[int]
    model: Optional[str] = ai.MODEL_GPT35


class ParamThesisId(_BaseFields):
    thesisId: int
    model: Optional[str] = ai.MODEL_GPT35


# 生成单独一段
class ParamGenerateSingleParagraph(_BaseFields):
    id: int = -1
    thesisId: int
    paragraphId: str
    title: Optional[str] = Field(default="标题")
    lang: Optional[str] = Field(default="中文")
    paragraph: Optional[str] = Field(default="")
    paragraphTitle: Optional[str] = Field(default="")
    length: Optional[int] = Field(default=500)
    instruction: Optional[str] = Field(default="")
    model: Optional[str] = ai.MODEL_GEMINI10


# 生成摘要
class ParamRegenDigest(_BaseFields):
    thesisId: int
    title: Optional[str]
    lang: Optional[str]
    outline: dict
    model: Optional[str] = ai.MODEL_GEMINI10
